/**
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-17 10:58:33
 * @Description  : 试卷修改接口路由
 */
const Router = require('koa-router')
const { verifyToken } = require('@/utils/jwt')
const paperValidate = require('@/middlewares/validateMiddlewares/paperValidate')
const paperController = require('@/controller/paperController')
const { verifyAdmin } = require('@/middlewares/validateMiddlewares/verifyAdmin')
const {
  validateSlideCode
} = require('@/middlewares/validateMiddlewares/userValidate')

const router = new Router()

/**
 * 获取试卷列表
 */
router.get(
  '/list',
  // verifyToken(),
  paperValidate.listPaperValidate,
  paperController.listPaper
)

/**
 * 根据ID获取试卷列表
 */
router.get(
  '/list/id',
  // verifyToken(),
  paperValidate.getPaperByIdValidate,
  paperController.getPaperById
)

/**
 * 创建试卷列表
 */
router.post(
  '/create',
  verifyToken(),
  verifyAdmin(),
  paperValidate.createPaperValidate,
  paperController.createPaper
)

/**
 * 更新试卷列表
 */
router.put(
  '/update',
  verifyToken(),
  verifyAdmin(),
  paperValidate.updatePaperValidate,
  paperController.updatePaper
)

/**
 * 试卷变更章节
 */
router.put(
  '/changeChapter',
  verifyToken(),
  verifyAdmin(),
  paperValidate.changeChapterValidate,
  paperController.changeChapterPaper
)

/**
 * 删除试卷列表
 */
router.delete(
  '/delete',
  validateSlideCode(),
  verifyToken(),
  verifyAdmin(),
  paperValidate.delPapersValidate,
  paperController.delPapers
)

/**
 * 试卷排序
 */
router.put(
  '/sort',
  verifyToken(),
  verifyAdmin(),
  paperValidate.delPapersValidate,
  paperController.sortPapers
)

/**
 * 试卷导出word的相关逻辑
 */

router.post(
  '/export',
  verifyToken(),
  verifyAdmin(),
  paperController.exportPaper
)

module.exports = router
